# -*- coding: utf-8 -*-
import sys
import xlrd  
#Bimport xlutils.copy


# https://pypi.python.org/packages/source/x/xlrd/xlrd-0.9.3.tar.gz#md5=6f3325132f246594988171bc72e1a385

PATH_LIB_XLRD = "./xlrd-0.9.3/xlrd/"
if not PATH_LIB_XLRD in sys.path:
    sys.path.append(PATH_LIB_XLRD)

PATH_LIB_XLWT = "./xlwt-0.7.5/xlwt/"
if not PATH_LIB_XLWT in sys.path:
    sys.path.append(PATH_LIB_XLWT)

import xlrd,xlwt
# data = xlrd.open_workbook('URN.xls')

# print xlwt

# # data = xlwt.open_workbook('URN.xls')
# # table = data.sheet_by_index(0)

# # nrows = table.nrows

# # ncols = table.ncols

# # for i in range(nrows ):
# #     print table.row_values(i)



# from openpyxl import Workbook, load_workbook

# wb = Workbook()
# ws = wb.create_sheet()
# ws.title = 'Pi'
# ws.cell('F5').value = 3.14156265
# wb.save(filename=r'URN.xls')

# # Re-opening the file:
# wb_re_read = load_workbook(filename=r'URN.xls')
# sheet = wb_re_read.get_sheet_by_name('Pi')
# print sheet.cell('F5').value




  
if __name__ == '__main__':  
    # template = u"1.xls"  
    # workBook = xlrd.open_workbook(template, on_demand=True, formatting_info=True)  
    # workBook = xlutils.copy.copy(workBook)  
    # sheet = workBook.get_sheet(0)  
    # sheet.write(0, 0, 'changed!111')  
    # workBook.save('1.xls')  

    import openpyxl
    from openpyxl.style import Color, Fill
    from openpyxl.cell import get_column_letter
    from openpyxl import Workbook
    wb = Workbook()
    ws = wb.active
    ws1 = wb.create_sheet()
    ws.title = "New Title"
    ws3 = wb["New Title"]
    ws4 = wb.get_sheet_by_name("New Title")
    ws is ws3 is ws4
    print wb.get_sheet_names()
    for sheet in wb:
        print wb
    ws['A4'] = 4
    wb.save('balances.xlsx')

    from openpyxl import load_workbook
    wb2 = load_workbook('balances.xlsx')
    ws5 = wb2.get_sheet_by_name("New Title")
    ws5['A5'] = 6

    #cell = sheet.cell(column=pt[0], row=pt[1])
    ws5['A5'].style.fill.fill_type = Fill.FILL_SOLID
    ws5['A5'].style.fill.start_color = Color(Color.BLACK)
    ws5['A5'].style.fill.end_color = Color(Color.BLACK)
    wb2.save('balances.xlsx')